const {role}=require("../model/index")

class RoleService{
    async addRole(role_name,description) {
        try {
            await role.create({
                role_name,
                description,
            })
        } catch (error) {
            console.log(error)
        }
    }
    async getRoleList() {
        try {
            let res = await role.findAll({})
            return res
        } catch (error) {
            console.log(error)
        }
    }
    async ModifyUserRoleById(id,role_name,description) {
        try {
            await role.update({
                role_name,
                description
            }, {
                where: {
                    id
                }
            })
        } catch (error) {
            console.log(error)
        }
    }
    async DeleteRoleById(id) {
        try {
            await role.destroy({
                where: {
                    id
                }
            })
        } catch (error) {
            console.log(error)
        }
    }
}
module.exports=new RoleService()